package com.qf.service;


import com.qf.mapper.UserMapper;
import com.qf.utils.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.concurrent.ThreadPoolExecutor;

@Service
public class UserServiceImpl {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private ThreadPoolExecutor threadPoolExecutor;

    @Scheduled(cron = "0/20 * * * * ? " )
    public void insertList(){
        System.out.println("执行"+new Date());
        for (int i = 0; i < 10; i++) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int j = 0; j < 20; j++) {
                        userMapper.addList(UserUtil.userList(5000));
                    }


                }
            });
            threadPoolExecutor.execute(thread);

        }



    }






}
